feat(cli): allow org credential options anywhere in the command#35
Open
buckleypaul wants to merge 1 commit into
Open
feat(cli): allow org credential options anywhere in the command#35buckleypaul wants to merge 1 commit into
buckleypaul wants to merge 1 commit into
Conversation
The org group's --org-id/-o and --token/-t had to precede the subcommand because Click parses group options before the subcommand name. Add a custom Group (_CredAnywhereGroup) that hoists these options (and their values) to the front of the argument list before parsing, so they can appear before or after the subcommand and its options, e.g.: hubblenetwork org register-device -e AES-128-EAX -o ORG -t TOKEN Rebind `org get-packets` output-format flag from -o to -f, since -o is now reserved for --org-id group-wide.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The
orggroup's--org-id/-oand--token/-thad to be placed immediately afterorg(before the subcommand), because Click parses group-level options before the subcommand name. This makes them positionable anywhere inorgcommands, so the following now works:Changes
_CredAnywhereGroup(click.Group), which hoists--org-id/-oand--token/-t(and their attached/=/space-separated values) to the front of the argument list before parsing. Credentials now work both before and after the subcommand and its options — no breaking change to the old position.org get-packets's output-format flag from-oto-f, since-ois now reserved for--org-idacross the wholeorggroup. (--formatlong form is unchanged.)Note: minor breaking change
org get-packets DEVICE -o json→ useorg get-packets DEVICE -f json(or--format json).-oonget-packetsnow means org-id.Testing
tests/test_org_option_position.pycovers creds before/after/interspersed with the subcommand,--org-id=/--token=forms, space-separated long forms, and-o(org-id) /-f(format) coexistence onget-packets.ruff check srcclean.